import type { Graph } from "@antv/x6";

const NodeId = "WaitNode";
const NodeLabel = "等待";

const properties = [
  {
    groupName: "通用",
    groupId: "common",
    items: [{
      "key": "name", 
      "name": "名称", 
      "val": "",
      "valType": "String"
    },{
      "key": "description", 
      "name": "描述", 
      "val": "",
      "valType": "String"
    }]
  },{
    groupName: "参数",
    groupId: "params",
    items: [{
      "key": "duration", 
      "name": "等待时间",
      "val": "",
      "valType": "String"
    }]
  }
]

export const createWaitNode = (graph:Graph)=>{
    const node = graph.createNode({
        shape: "rect",
        width: 80,
        height: 30,
        label: NodeLabel,
        attrs: commonAttrs,
        data: {
            id: NodeId,
            properties: properties
        },
        ports: {
            groups: {
              output: {
                position: 'bottom',
                attrs: {
                  circle: {
                    magnet: true,
                    stroke: '#8f8f8f',
                    r: 5,
                  },
                },
                label: {
                  position: 'top',
                },
              },
            },
        },
    });
    
    return node;
}



export const getWaitDropNode=(node:any)=>{
    node.addPort({
        group: "output",
        attrs: {
        //   text: {
        //     text: "xx",
        //   },
        },
    });
    return node;
}

const commonAttrs = {
  body: {
      fill: '#fff',
      stroke: '#8f8f8f',
      strokeWidth: 1,
  },
}
